﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">

    <LinearGradientBrush x:Key="ButtonNormalBrush" EndPoint="0.5,1" StartPoint="0.5,0">
        <GradientStop Color="#FFFFFFFF" Offset="0" />
        <GradientStop Color="#FFC7DEF9" Offset="0.521" />
        <GradientStop Color="#FFC6D6EC" Offset="0.194" />
        <GradientStop Color="#FFDFEAF7" Offset="0.811" />
        <GradientStop Color="#FFDAE5F3" Offset="0.507" />
        <GradientStop Color="#FFE3EEFB" Offset="1" />
    </LinearGradientBrush>
    <LinearGradientBrush x:Key="ButtonNormalBorderBrush" EndPoint="0.5,0" StartPoint="0.5,1">
        <GradientStop Color="#FF84B2D4" />
        <GradientStop Color="#FFADC7DE" Offset="1" />
    </LinearGradientBrush>
    <SolidColorBrush x:Key="ButtonNormalHighlightBrush" Color="#FFFFFFFF"/>
    <LinearGradientBrush x:Key="ButtonMouseOverBrush" EndPoint="0.5,1" StartPoint="0.5,0">
        <GradientStop Color="#FFFFFFFF" Offset="0" />
        <GradientStop Color="#FFFEF3B5" Offset="0.318" />
        <GradientStop Color="#FFFFEB70" Offset="0.488" />
        <GradientStop Color="#FFFFD02E" Offset="0.502" />
        <GradientStop Color="#FFFFD932" Offset="0.834" />
        <GradientStop Color="#FFFFF48B" Offset="1" />
    </LinearGradientBrush>
    <LinearGradientBrush x:Key="ButtonMouseOverBorderBrush" EndPoint="0.5,1" StartPoint="0.5,0">
        <GradientStop Color="#FFEEE8CF" Offset="0" />
        <GradientStop Color="#FFC4AF8C" Offset="0.536" />
        <GradientStop Color="#FFDCD1BF" Offset="1" />
    </LinearGradientBrush>
    <LinearGradientBrush x:Key="ButtonMouseOverHighlightBrush" EndPoint="0.5,1" StartPoint="0.5,0">
        <GradientStop Color="#FFFFFFFB" Offset="0" />
        <GradientStop Color="#FFFEF3B5" Offset="1" />
    </LinearGradientBrush>
    <LinearGradientBrush x:Key="ButtonPressedBrush" EndPoint="0.5,1" StartPoint="0.5,0">
        <GradientStop Color="#FFC3BCAE" Offset="0" />
        <GradientStop Color="#FFD5F3FF" Offset="0.046" />
        <GradientStop Color="#FF9BDFFF" Offset="0.724" />
        <GradientStop Color="#FFB5C6F5" Offset="1" />
    </LinearGradientBrush>
    <LinearGradientBrush x:Key="ButtonPressedBorderBrush" EndPoint="0.5,1" StartPoint="0.5,0">
        <GradientStop Color="#FF8E8165" Offset="0" />
        <GradientStop Color="#FFC3BCAE" Offset="1" />
    </LinearGradientBrush>
    <LinearGradientBrush x:Key="ButtonPressedHighlightBrush" EndPoint="0.5,1" StartPoint="0.5,0">
        <GradientStop Color="#FFFFFFFF" Offset="0.665" />
        <GradientStop Color="#FFC3BCAE" Offset="0" />
    </LinearGradientBrush>
    <SolidColorBrush x:Key="ButtonDisabledBackgroundBrush" Color="#A5FFFFFF"/>
    <SolidColorBrush x:Key="ButtonDisabledBorderBrush" Color="#66FFFFFF"/>
    <SolidColorBrush x:Key="ButtonFocusBrush" Color="#FFE99862"/>


    <ControlTemplate x:Key="BasicButtonTemplate" TargetType="{x:Type Button}">
        <ControlTemplate.Resources>
            <Storyboard x:Key="HoverOn">
                <DoubleAnimation Duration="00:00:00.1000000" Storyboard.TargetName="BackgroundOver" Storyboard.TargetProperty="Opacity" To="1" />
                <DoubleAnimation Duration="00:00:00.1000000" Storyboard.TargetName="BackgroundOver_Highlight" Storyboard.TargetProperty="Opacity" To="0.65" />
            </Storyboard>
            <Storyboard x:Key="HoverOff">
                <DoubleAnimation Duration="00:00:00.4000000" Storyboard.TargetName="BackgroundOver" Storyboard.TargetProperty="Opacity" To="0" />
                <DoubleAnimation Duration="00:00:00.4000000" Storyboard.TargetName="BackgroundOver_Highlight" Storyboard.TargetProperty="Opacity" To="0" />
            </Storyboard>
            <Storyboard x:Key="PressedOn">
                <DoubleAnimation Duration="00:00:00.1000000" Storyboard.TargetName="BackgroundPressed" Storyboard.TargetProperty="Opacity" To="0.84" />
                <DoubleAnimation Duration="00:00:00.1000000" Storyboard.TargetName="BackgoundPressed_Highlight" Storyboard.TargetProperty="Opacity" To="0.65" />
            </Storyboard>
            <Storyboard x:Key="PressedOff">
                <DoubleAnimation Duration="00:00:00.4000000" Storyboard.TargetName="BackgroundPressed" Storyboard.TargetProperty="Opacity" To="0" />
                <DoubleAnimation Duration="00:00:00.4000000" Storyboard.TargetName="BackgoundPressed_Highlight" Storyboard.TargetProperty="Opacity" To="0" />
            </Storyboard>
            <Storyboard x:Key="DisabledOn">
                <ObjectAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="DisabledVisualElement" Storyboard.TargetProperty="(UIElement.Visibility)">
                    <DiscreteObjectKeyFrame KeyTime="00:00:00.1000000" Value="{x:Static Visibility.Visible}" />
                </ObjectAnimationUsingKeyFrames>
            </Storyboard>
            <Storyboard x:Key="FocusedOn">
                <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="FocusVisualElement" Storyboard.TargetProperty="(UIElement.Opacity)">
                    <SplineDoubleKeyFrame KeyTime="00:00:00.1000000" Value="1" />
                </DoubleAnimationUsingKeyFrames>
            </Storyboard>
            <Storyboard x:Key="FocusedOff">
                <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="FocusVisualElement" Storyboard.TargetProperty="(UIElement.Opacity)">
                    <SplineDoubleKeyFrame KeyTime="00:00:00.3000000" Value="0" />
                </DoubleAnimationUsingKeyFrames>
            </Storyboard>
        </ControlTemplate.Resources>
        <Grid x:Name="Grid">
            <Border x:Name="BackgroundNorm" BorderThickness="1" CornerRadius="1.75" Background="{DynamicResource ButtonNormalBrush}" BorderBrush="{DynamicResource ButtonNormalBorderBrush}"/>
            <Border x:Name="BackgroundNorm_highlight" Margin="1" BorderBrush="{DynamicResource ButtonNormalHighlightBrush}" BorderThickness="1,0,1,1" CornerRadius="1" Opacity="0.65" />
            <Border x:Name="BackgroundOver" BorderThickness="1" CornerRadius="1.75" Opacity="0" Background="{DynamicResource ButtonMouseOverBrush}" BorderBrush="{DynamicResource ButtonMouseOverBorderBrush}"/>
            <Border x:Name="BackgroundOver_Highlight" Margin="1" BorderThickness="1,0,1,1" CornerRadius="1" Opacity="0" BorderBrush="{DynamicResource ButtonMouseOverHighlightBrush}"/>
            <Border x:Name="BackgroundPressed" BorderThickness="1" CornerRadius="1.75" Opacity="0" Background="{DynamicResource ButtonPressedBrush}" BorderBrush="{DynamicResource ButtonPressedBorderBrush}"/>
            <Border x:Name="BackgoundPressed_Highlight" Margin="1" BorderThickness="1,0,1,1" CornerRadius="1" Opacity="0" BorderBrush="{DynamicResource ButtonPressedHighlightBrush}"/>
            <Border x:Name="DisabledVisualElement" IsHitTestVisible="false" Background="{DynamicResource ButtonDisabledBackgroundBrush}" BorderBrush="{DynamicResource ButtonDisabledBorderBrush}" BorderThickness="1" Opacity="0" />

            <ContentPresenter x:Name="contentPresenter" RecognizesAccessKey="True" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Margin="{TemplateBinding Padding}" />
            <Border x:Name="FocusVisualElement" Margin="-1" BorderBrush="{DynamicResource ButtonFocusBrush}" BorderThickness="1" CornerRadius="2.75" IsHitTestVisible="false" Opacity="0" />
            <Border x:Name="DefaultBorder" Margin="-1" BorderBrush="{DynamicResource ButtonFocusBrush}" BorderThickness="1" CornerRadius="2.75" IsHitTestVisible="false" Opacity="0" />
        </Grid>

        <ControlTemplate.Triggers>
            <Trigger Property="IsDefault" Value="True">
                <Setter Property="Opacity" TargetName="DefaultBorder" Value="1" />
            </Trigger>
            <Trigger Property="IsFocused" Value="True">
                <Trigger.EnterActions>
                    <BeginStoryboard x:Name="FocusedOn_BeginStoryboard" Storyboard="{StaticResource FocusedOn}" />
                </Trigger.EnterActions>
                <Trigger.ExitActions>
                    <BeginStoryboard x:Name="FocusedOff_BeginStoryboard" Storyboard="{StaticResource FocusedOff}" />
                </Trigger.ExitActions>
            </Trigger>
            <Trigger Property="IsKeyboardFocused" Value="True">

                <Trigger.ExitActions>
                    <BeginStoryboard x:Name="FocusedOff_BeginStoryboard1" Storyboard="{StaticResource FocusedOff}" />
                </Trigger.ExitActions>
                <Trigger.EnterActions>
                    <BeginStoryboard x:Name="FocusedOn_BeginStoryboard1" Storyboard="{StaticResource FocusedOn}" />
                </Trigger.EnterActions>

            </Trigger>
            <Trigger Property="IsMouseOver" Value="True">
                <Trigger.ExitActions>
                    <BeginStoryboard Storyboard="{StaticResource HoverOff}" x:Name="HoverOff_BeginStoryboard" />
                </Trigger.ExitActions>
                <Trigger.EnterActions>
                    <BeginStoryboard Storyboard="{StaticResource HoverOn}" />
                </Trigger.EnterActions>

            </Trigger>
            <Trigger Property="IsPressed" Value="True">
                <Trigger.ExitActions>
                    <BeginStoryboard Storyboard="{StaticResource PressedOff}" />
                </Trigger.ExitActions>
                <Trigger.EnterActions>
                    <BeginStoryboard Storyboard="{StaticResource PressedOn}" />
                </Trigger.EnterActions>
            </Trigger>
            <Trigger Property="IsEnabled" Value="False">
                <Trigger.EnterActions>
                    <BeginStoryboard Storyboard="{StaticResource DisabledOn}" />
                </Trigger.EnterActions>

                <Setter Property="Foreground" Value="{DynamicResource DisabledForegroundBrush}" />
                <Setter Property="Opacity" TargetName="DisabledVisualElement" Value="0.5" />
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <Style x:Key="BasicButton" BasedOn="{x:Null}" TargetType="{x:Type Button}">
        <Setter Property="Template" Value="{StaticResource BasicButtonTemplate}" />
    </Style>

</ResourceDictionary>